// Componet/model/model.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    param:Object
  },

  /**
   * 组件的初始数据
   */
  data: {
    title: "",
    adress: "",
    phone: "",
    weixin: "",
    display: "black",
  },

  attached: function(e) {
    let that = this;
    console.log(e)
    console.log("this.dataset.adress:" + this.dataset.adress); //控制台打印:"400-010-9797"
    // 设置properties值用setData()
    this.setData({
      phone:that.properties.param.phone,
      weixin: that.properties.param.weixin,
      adress: that.properties.param.adress
    })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    change: function () {
      this.triggerEvent('chand', { display: "none" });
    },
    //地址复制
    adressPaste() {
      var that = this;
      wx.showToast({
        title: '复制成功',
      })
      wx.setClipboardData({
        data: that.data.adress,
        success: function(res) {
          wx.getClipboardData({
            // 这个api是把拿到的数据放到电脑系统中的
            success: function(res) {
              console.log(res.data) // data
            }
          })
        }
      })
    },
    close:function () {
      console.log("出发了")
      this.triggerEvent('close', "调用了");
    },
    //电话复制
    phonePaste() {
      var that = this;
      wx.showToast({
        title: '复制成功',
      })
      wx.setClipboardData({
        data: that.data.phone,
        success: function(res) {
          wx.getClipboardData({
            // 这个api是把拿到的数据放到电脑系统中的
            success: function(res) {
              console.log(res.data) // data
            }
          })
        }
      })
    },
    //微信复制
    weixinPaste() {
      var that = this;
      wx.showToast({
        title: '复制成功',
      })
      wx.setClipboardData({
        data: that.data.weixin,
        success: function(res) {
          wx.getClipboardData({
            // 这个api是把拿到的数据放到电脑系统中的
            success: function(res) {
              console.log(res.data) // data
            }
          })
        }
      })
    },
  }
})